﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SKYPE4COMLib;

namespace SmartVoice
{
    class SkypeLink
    {
        public Skype skype = new Skype();

        public SkypeLink()
        {
            if (!skype.Client.IsRunning)
            {
                skype.Client.Start(true, true);
            }
            try
            {
                skype.Attach(7, false);
            }
            catch (Exception) { }
        }

        public List<IUser> GetAllContacts()
        {
            IUser user;
            List<IUser> users = new List<IUser>();
            int i, j;
            for (i = 1; i <= skype.HardwiredGroups.Count; i++)
            {
                for (j = 1; j <= skype.HardwiredGroups[i].Users.Count; j++)
                {
                    user = skype.HardwiredGroups[i].Users[j];
                    users.Add(user);
                }
            }

            for (i = 1; i <= skype.CustomGroups.Count; i++)
            {
                for (j = 1; j <= skype.CustomGroups[i].Users.Count; j++)
                {
                    user = skype.CustomGroups[i].Users[j];
                    users.Add(user);
                }
            }
            return users;
        }
    }
}
